package com.sparrow.manage.noauth;

import com.sparrow.manage.comment.Comment;
import com.sparrow.manage.comment.CommentController;
import com.sparrow.manage.common.entity.result.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 没有权限验证的Controller<br/>
 * 注意使用IP限制, 验证码等手段限制访问<br/>
 * 为了代码调用清晰, 这里应该只注入Controller层的对象<br/>
 */
@Controller
@RequestMapping("/external")
public class ExternalController {

    @Autowired
    private CommentController commentController;



    @ResponseBody
    @RequestMapping("/sayHello")
    public Result sayHello(Comment comment){
        // 不需要登录, 直接插入数据
        // 规则:
        //      1. 验证码
        //      2. 一个ip一天提交5条记录
        comment.setType(Comment.CommentType.NET_WORD.getCode());
        return commentController.sayHello(comment);
    }


}
